From f5de363eff322d17f0eecdaad7f653ecb8d338f5 Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Fri, 7 Apr 2006 14:27:46 +0100 Subject: [PATCH] Turn pirq_mask into a generic bitmap type. Signed-off-by: Keir Fraser --- xen/arch/ia64/xen/irq.c | 27 +++++++++++---------------- xen/arch/x86/irq.c | 28 +++++++++++----------------- xen/include/xen/sched.h | 2 +- 3 files changed, 23 insertions(+), 34 deletions(-) diff --git a/xen/arch/ia64/xen/irq.c b/xen/arch/ia64/xen/irq.c index c42b5e2944..e7d0862d9c 100644 --- a/xen/arch/ia64/xen/irq.c +++ b/xen/arch/ia64/xen/irq.c @@ -1358,25 +1358,20 @@ static void __do_IRQ_guest(int irq) int pirq_guest_unmask(struct domain *d) { irq_desc_t *desc; - int i, j, pirq; - u32 m; + int pirq; shared_info_t *s = d->shared_info; - for ( i = 0; i < ARRAY_SIZE(d->pirq_mask); i++ ) + for ( pirq = find_first_bit(d->pirq_mask, NR_PIRQS); + pirq < NR_PIRQS; + pirq = find_next_bit(d->pirq_mask, NR_PIRQS, pirq) ) { - m = d->pirq_mask[i]; - while ( (j = ffs(m)) != 0 ) - { - m &= ~(1 << --j); - pirq = (i << 5) + j; - desc = &irq_desc[pirq]; - spin_lock_irq(&desc->lock); - if ( !test_bit(d->pirq_to_evtchn[pirq], &s->evtchn_mask[0]) && - test_and_clear_bit(pirq, &d->pirq_mask) && - (--((irq_guest_action_t *)desc->action)->in_flight == 0) ) - desc->handler->end(pirq); - spin_unlock_irq(&desc->lock); - } + desc = &irq_desc[pirq]; + spin_lock_irq(&desc->lock); + if ( !test_bit(d->pirq_to_evtchn[pirq], &s->evtchn_mask[0]) && + test_and_clear_bit(pirq, &d->pirq_mask) && + (--((irq_guest_action_t *)desc->action)->in_flight == 0) ) + desc->handler->end(pirq); + spin_unlock_irq(&desc->lock); } return 0; diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c index b260e9d627..0b9d88037b 100644 --- a/xen/arch/x86/irq.c +++ b/xen/arch/x86/irq.c @@ -171,26 +171,20 @@ static void __do_IRQ_guest(int vector) int pirq_guest_unmask(struct domain *d) { irq_desc_t *desc; - unsigned int i, j, pirq; - u32 m; + unsigned int pirq; shared_info_t *s = d->shared_info; - for ( i = 0; i < ARRAY_SIZE(d->pirq_mask); i++ ) + for ( pirq = find_first_bit(d->pirq_mask, NR_PIRQS); + pirq < NR_PIRQS; + pirq = find_next_bit(d->pirq_mask, NR_PIRQS, pirq) ) { - m = d->pirq_mask[i]; - while ( m != 0 ) - { - j = find_first_set_bit(m); - m &= ~(1 << j); - pirq = (i << 5) + j; - desc = &irq_desc[irq_to_vector(pirq)]; - spin_lock_irq(&desc->lock); - if ( !test_bit(d->pirq_to_evtchn[pirq], &s->evtchn_mask[0]) && - test_and_clear_bit(pirq, &d->pirq_mask) && - (--((irq_guest_action_t *)desc->action)->in_flight == 0) ) - desc->handler->end(irq_to_vector(pirq)); - spin_unlock_irq(&desc->lock); - } + desc = &irq_desc[irq_to_vector(pirq)]; + spin_lock_irq(&desc->lock); + if ( !test_bit(d->pirq_to_evtchn[pirq], &s->evtchn_mask[0]) && + test_and_clear_bit(pirq, &d->pirq_mask) && + (--((irq_guest_action_t *)desc->action)->in_flight == 0) ) + desc->handler->end(irq_to_vector(pirq)); + spin_unlock_irq(&desc->lock); } return 0; diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 1ea48aae7d..bd01f83d27 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -134,7 +134,7 @@ struct domain */ #define NR_PIRQS 256 /* Put this somewhere sane! */ u16 pirq_to_evtchn[NR_PIRQS]; - u32 pirq_mask[NR_PIRQS/32]; + DECLARE_BITMAP(pirq_mask, NR_PIRQS); /* I/O capabilities (access to IRQs and memory-mapped I/O). */ struct rangeset *iomem_caps; -- 2.30.2